package com.visionet.waveletData.web.repository.plan.impl;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by hxpeng on 2017/1/11.
 */
@Repository
public class PlanFileDaoImpl {

    private final static Logger logger = LoggerFactory.getLogger(PlanFileDaoImpl.class);

    @Resource
    private JdbcTemplate jdbcTemplate;

    public int findAllByGroupId(String groupId){
        StringBuffer sql = new StringBuffer();
        List<Object> params = new ArrayList<Object>();
        sql.append("select ppg.id,ppg.is_deleted from p_plan_group as ppg where ppg.is_deleted='0' ");
        if(StringUtils.isNotBlank(groupId)){
            sql.append(" and ppg.group_id = ?");
            params.add(groupId);
        }
        int size = jdbcTemplate.queryForInt("select count(*) from ("+sql.toString()+") as c", params.toArray());
        return size;
    }

}
